﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.ProjectDevelopViewModel

<link href="@Url.Content("~/Assets/plugins/bootstrap-select/bootstrap-select.min.css")" rel="stylesheet" />
<script src="@Url.Content("~/Assets/plugins/bootstrap-select/bootstrap-select.min.js")"></script>
<link href="@Url.Content("~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css")" rel="stylesheet" />
<link href="@Url.Content("~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css")" rel="stylesheet" />
<script src="@Url.Content("~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js")"></script>
<script src="@Url.Content("~/Assets/plugins/chosen/chosen.jquery.min.js")"></script>
<script src="@Url.Content("~/Assets/js/pages/form-elements.js")"></script>

<style>
   ul>.active {
       font-weight:bold
   }
   .bootstrap-select  {
       width: 100%;
   }
   #table_CreateProject td {
       padding-left: 5px;
       padding-top: 5px
   }
    
</style>

<script>
    window.onload = function () {
        $("#datetimepicker").datepicker({
            autoclose: true,
            pickerPosition:"bottom-right"
        });
    };
</script>
<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index", "Home", new { area = "" })"><i class="icon fa fa-home"></i>主页</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>项目模块</a></li>
        </ol>
    </div>
</div>

@{
    if (ViewBag.CreateProjectFlag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;项目添加成功！</strong>
    </div>
    }
    if (ViewBag.CreateProjectFlag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;项目添加失败！</strong> @ViewBag.Info
    </div>
    }
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span class="break"></span>项目列表</h6>
                @{
                    if (ViewBag.IsAdmin == true)
                    {
                    <div class="panel-actions">
                        <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新增项目&nbsp;&nbsp;</a>
                    </div>
                    }
                }
            </div>
            <div class="panel-body">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a style="color:black" href="#overview" data-toggle="tab">未完成</a>
                        </li>
                        <li class="">
                            <a style="color:black" href="#edit" data-toggle="tab">已完成</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="overview" class="tab-pane active">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover"style="text-align: center">
                                        <thead>
                                            <tr>
                                                <th style="width:10%;text-align: center">编号</th>
                                                <th style="width:40%;text-align: center">项目名称</th>
                                                <th style="width:30%;text-align: center">项目负责人</th>
                                                <th style="width:10%;text-align: center">项目创建日期</th>
                                                <th style="width:10%;text-align: center">优先级</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.ExecuteProjectList.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.ExecuteProjectList.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.ExecuteProjectList.Tables[0].Rows[i];
                                                <tr>
                                                    <td style="color: black">@item["PROJECT_NO"]
                                                    </td>
                                                    <td><a  style="color:cornflowerblue" href="@Url.Action("ProjectInfo", "Project", new { area = "DevelopArea", projectId = item["PROJECT_DEVELOP_ID"].ToString() })">@item["PROJECT_NAME"]</a></td>
                                                    <td style="color: black">@item["PROJECT_LEADER"]</td>
                                                    <td style="color: black">@Convert.ToDateTime(item["CREATETIME"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="color: black">@item["PROJECT_LEVEL"]</td>
                                                    @*<td>
                                                                        <div class="progress">
                                                                            <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 45%;">
                                                                                45%
                                                                            </div>
                                                                        </div>
                                                                    </td>*@
                                                </tr>
                                                    }
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalExecute"])
                                </div>
                            </div>
                        </div>
                        <div id="edit" class="tab-pane updateProfile">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th>编号
                                                </th>
                                                <th>项目名称</th>
                                                <th>项目负责人</th>
                                                <th>项目创建日期</th>
                                                <th>优先级</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.FinishProjectList.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.FinishProjectList.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.FinishProjectList.Tables[0].Rows[i];
                                                <tr>
                                                    <td style="color: black">
                                                        @item["PROJECT_NO"]
                                                    </td>
                                                    <td><a style="color:cornflowerblue" href="@Url.Action("ProjectInfo", "Project", new { area = "DevelopArea", projectId = item["PROJECT_DEVELOP_ID"] })">@item["PROJECT_NAME"]</a></td>
                                                    <td style="color: black">@item["PROJECT_LEADER"]</td>
                                                    <td style="color: black">@item["CREATETIME"]</td>
                                                    <td style="color: black">@item["PROJECT_LEVEL"]</td>
                                                </tr>
                                                    }
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexFinish"], (int)ViewData["pageSizeFinish"], (int)ViewData["totalFinish"])
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <script>
        function SubmitCreate()
        {
            var message = "";
            if ($("#tb_ProjectName").val().length>30)
            {
                message += " · 项目名称不能超过30字符" + "<br/>";
            }
            if ($("#tb_ProjectName").val() == "" || $.trim($("#tb_ProjectName").val()) == "")
            {
                message += " · 项目名称不能为空" + "<br/>";
            }
            
            if ($("#tb_DevelopDescription").val() == "")
            {
                message += " · 项目描述不能为空" + "<br/>";
            }
            if ($("#tb_DevelopDescription").text().length >200)
            {
                message += " · 项目描述不能超过200个字符" + "<br/>";
            }
            if ($("#select_ProjectLeader").val() == "" || $.trim($("#select_ProjectLeader").val()) == "")
            {
                message += " · 负责人不能为空" + "<br/>";
            }

            if ($("#select_ProjectEmp").val() == "" || $.trim($("#select_ProjectEmp").val()) == "")
            {
                message += " · 项目人员不能为空" + "<br/>";
            }
            if ($("#select_BusinessType").val() == "")
            {
                message += " · 业务类型不能为空" + "<br/>";
            }

            if (message != "")
            {
                $("#lb_CheckCreateProjectMessage").html(message);
                $("#div_CheckCreateProjectMessage").css("display", "block");
                return false;
            }
            else
            {
                $("#lb_CheckCreateProjectMessage").html("");
                $("#div_CheckCreateProjectMessage").css("display", "none");
                $("#frm_CreateProject").submit();
            }
        }
    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
    </style>
    <div class="modal-dialog" style="width: 650px;">
        <div class="modal-content" >
            <form id="frm_CreateProject" action="@Url.Action("CreateProject", "Project", new { area = "DevelopArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">新增项目
                    </h4>
                    
                </div>
                <div class="alert alert-danger" id="div_CheckCreateProjectMessage" style="display: none">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>
                            <label id="lb_CheckCreateProjectMessage"></label>
                        </strong>
                    </div>
                <div id="div_CreateProject" class="modal-body">
                    
                    <table id="table_CreateProject" >
                        <tr>
                            <td >项目名称:</td>
                            <td colspan="3" >
                             
                                    <table style="width:100%">
                                        <tr>
                                            <td style="width:80%">
                                                <input id="tb_ProjectName" style="border-color: cornflowerblue; width: 100%" name="tb_ProjectName" class="form-control" placeholder="Text" type="text" />
                                   
                                            </td>
                                            <td style="width:20%">
                                                 <a data-toggle="modal" data-target="#ProjectSelectModal">
                                                    <input type="button"  value="..." />
                                                </a>
                                            </td>
                                        </tr>
                                    </table>
                           
                            </td>
                        </tr>
                        <tr>
                            <td>负责人：</td>
                            <td>
                                 <select  name="select_ProjectLeader" id="select_ProjectLeader" class="form-control selectpicker" multiple="multiple">
                                @{
                                    List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["UserList"];
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            var item = userList[i];
                                            <option value="@item.UserId">@item.UserName</option>
                                        }
                                    }
                                    
                                }
                            </select>
                            </td>
                            <td>项目人员：</td>
                            <td>
                                <select name="select_ProjectEmp" id="select_ProjectEmp" class="form-control selectpicker"
                                multiple="multiple">
                                @{
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            var item = userList[i];
                                    <option value="@item.UserId">@item.UserName</option>
                                        }
                                    }
                                }
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td>截至日期：</td>
                            <td>
                                <!-- class="input-append date"-->
                                <div class="input-append date" id="datetimepicker" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                    <input name="tb_DeadTime" style="border-color: cornflowerblue" class="form-control" size="16" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                    <span class="add-on"><i class="icon-th"></i></span>
                                </div>
                            </td>
                            <td>项目级别：</td>
                            <td>
                                <select name="select_ProjectLevel" class="form-control select2-active">
                                    <option value="Low">低</option>
                                    <option value="Normal">中</option>
                                    <option value="High">高</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>业务主管部门：</td>
                            <td>
                                <input id="tb_BusinessDepartment" name="tb_BusinessDepartment" class="form-control" placeholder="Text" type="text" />
                            </td>
                            <td>业务联系人：</td>
                            <td>
                                <input  id="tb_BusinessUser" name="tb_BusinessUser" class="form-control" placeholder="Text" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td>业务联系人电话：</td>
                            <td>
                                <input id="tb_BusinessUserTel" name="tb_BusinessUserTel" class="form-control" placeholder="Text" type="text" />
                            </td>
                            <td>业务类型：</td>
                            <td>
                                <select id="select_BusinessType" name="select_BusinessType" class="form-control select2-active">
                                    <option value="">请选择</option>
                                    <option value="办公">办公</option>
                                    <option value="政法">政法</option>
                                    <option value="关税">关税</option>
                                    <option value="监管">监管</option>
                                    <option value="加贸">加贸</option>
                                    <option value="行邮">行邮</option>
                                    <option value="统计">统计</option>
                                    <option value="稽查">稽查</option>
                                    <option value="缉私">缉私</option>
                                    <option value="财务">财务</option>
                                    <option value="人教">人教</option>
                                    <option value="监察">监察</option>
                                    <option value="关保">关保</option>
                                    <option value="政工">政工</option>
                                    <option value="督审">督审</option>
                                    <option value="科技">科技</option>
                                    <option value="其他">其他</option>
                                </select>
                            </td>
                        </tr>
                          <tr>
                            <td > 项目描述：</td>
                            <td colspan="3">
                                <textarea id="tb_DevelopDescription" name="tb_DevelopDescription" rows="5" class="form-control" placeholder="Content.."></textarea>
                            </td>
                        </tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="button" onclick="SubmitCreate()" value="提交更改" class="btn btn-primary" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
    
    

</div>



<script>
    function SelectProject() {
        var id = "";
        $("#ProjectSelectModal").find("input[type='radio']").each(function() {
            if ($(this).attr("checked") == "checked") {
                id= $(this).val();
            }
        });

       

        if (id!="") {
            $.ajax({
                type: "POST",
                //url: "/KSManager/DevelopArea/Project/ProjectManagentInfo",
                url:'@Url.Action("ProjectManagentInfo","Project",new{area="DevelopArea"})',
                data: "proId=" + id,
                cache: false,
                ifModified: true,
                beforeSend: function(xmlHttp) {
                    xmlHttp.setRequestHeader("If-Modified-Since", "0");
                    xmlHttp.setRequestHeader("Cache-Control", "no-cache");
                },
                error: function() { alert("服务器出错！"); },
                success: function(data) {
                    $("#myModal #tb_ProjectName").val(data["PROJECT_MANAGEMENT_TITLE"]);
                    //$("#myModal #tb_ProjectNo").val(data["PROJECT_MANAGEMENT_NO"]);
                    $("#myModal #tb_DevelopDescription").val(data["PROJECT_MANAGEMENT_CONTENT"]);
                    $("#myModal #tb_BusinessUser").val(data["PROJECT_MANAGEMENT_NO"]);
                    $("#myModal #tb_BusinessDepartment").val(data["PROJECT_MANAGEMENT_BUINESS_DEPARTMENT"]);
                    $("#myModal #tb_BusinessUserTel").val(data["PROJECT_MANAGEMENT_BUINESS_TEL"]);
                    $("#myModal #tb_BusinessUser").val(data["PROJECT_BUINESS_CONTACT"]);
                    $("#myModal #tb_BusinessDepartment").val(data["PROJECT_MANAGEMENT_BUINESS_DEPARTMENT"]);
                    
                }
            });
        }
        //$("#ProjectSelectModal").attr("aria-hidden", "false");
        //$("#ProjectSelectModal").modal('hide');
    }
</script>

<div class="modal fade"  id="ProjectSelectModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">其他项目选取
                </h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-danger" id="div_CheckEditUserPwdMessage" style="display: none">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <strong>
                        <label id="lb_CheckEditUserPwdMessage"></label>
                    </strong>
                </div>
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">可选项目：</label>
                    <div class="col-md-9">
                        @{
                            List<ProjectManagementInfoViewModel> list = ViewBag.ProjectManagents;
                            if (list != null&& list.Count!=0)
                                {
                                    for (int i = 0; i < list.Count(); i++)
                                    {
                                        <input id="rd_@list[i].PROJECT_MANAGEMENT_ID" name="ck_EditRoleMenu" value="@list[i].PROJECT_MANAGEMENT_ID"  type="radio" />
                                        <label for="lb_EditStatus">@list[i].PROJECT_MANAGEMENT_TITLE</label>
                                        @:&nbsp;&nbsp;
                                        if (i % 2 != 0)
                                        {
                                            <br/>
                                        }
                                    }
                                }
                            }
                    </div>
                </div>
                <br />

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
                <input type="button" onclick="SelectProject()" data-dismiss="modal" class="btn btn-primary"  value="选取" />
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
